import {API} from "../utils/request";

const DaiBanURL = '/daiban/'
const add = DaiBanURL + 'addDaiBan'
const getDaiBan = DaiBanURL + 'getDaiBan'
const deleteDaiBan = DaiBanURL + 'deleteDaiBan'
const updateDaiBan = DaiBanURL + 'updateDaiBan'
const updateDaiBanOne = DaiBanURL + 'updateAllDaiBan'

/**
 * 添加代办
 * @param data
 * @returns {Promise<unknown>}
 */
// export function addDaiBanAPI(data) {
//     return API({
//         url: add,
//         method: 'POST',
//         data: data
//     })
// }

export const addDaiBanAPI = (data) =>
    API({
        url: add,
        method: 'POST',
        data: data
    })

/**
 * 获取代办
 * @param data
 * @returns {Promise<unknown>}
 */
// export function getDaiBanAPI(data) {
//     return API({
//         url: getDaiBan + '?status=' + data,
//         method: 'GET'
//     })
// }
export const getDaiBanAPI = (data) => API({url: getDaiBan + '?status=' + data, method: 'GET'})

/**
 * 删除代办
 * @param data
 * @returns {Promise<unknown>}
 */
export function deleteDaiBanAPI(data) {
    return API({
        url: deleteDaiBan + '?id=' + data,
        method: 'DELETE',
    })
}

/**
 * 更新代办
 * @param data
 * @returns {Promise<unknown>}
 */
export function updateDaiBanAPI(data) {
    return API({
        // url: updateDaiBan + '?id=' + data.id + '&statusId=' + data.statusId,
        url: `${updateDaiBan}?id=${data.id}&statusId=${data.statusId}`,
        method: 'PUT',
    })
}

/**
 * 更新代办 全量
 * @param data
 * @returns {Promise<unknown>}
 */
export function updateDaiBanOneAPI(data) {
    return API({
        url: updateDaiBanOne,
        method: 'PUT',
        data: data
    })
}
